package com.usion.login.llist;

import cn.hutool.core.util.RandomUtil;
import com.usion.api.AliMessage.AliCode;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;


import java.util.concurrent.TimeUnit;

@Service
public class RabbliList {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RabbitListener(queues ="pp" )
    public void eandcodeLIst(Message message, String phone) throws Exception {
        AliCode aliCode=new AliCode();
        String s = RandomUtil.randomNumbers(6);
        aliCode.sendCode(phone,s );

        stringRedisTemplate.opsForValue().set(phone,s );
        stringRedisTemplate.expire(phone,3, TimeUnit.MINUTES );
    }

}
